/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-03-14
 * Time: 22:19
 */
public class student {
    // 实例字段
    private String name;
    private int age;

    // 构造方法
    public student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    // 实例方法：获取姓名
    public String getName() {
        return this.name;
    }

    // 实例方法：设置姓名
    public void setName(String name) {
        this.name = name;
    }

    // 实例方法：获取年龄
    public int getAge() {
        return this.age;
    }

    // 实例方法：显示学生信息
    public void displayInfo() {
        System.out.println("Student Information:");
        System.out.println("Name: " + this.name);
        System.out.println("Age: " + this.age);
    }

    public static void main(String[] args) {
        // 创建 Student 对象
        student student1 = new student("Alice", 20);

        // 调用实例方法
        student1.displayInfo(); // 输出学生信息

        // 修改学生信息
        student1.setName("Bob");

        // 再次显示学生信息
        System.out.println("\nUpdated Student Information:");
        student1.displayInfo();
    }
}


/*
运行
    Student Information:
        Name: Alice
        Age: 20

        Updated Student Information:
        Student Information:
        Name: Bob
        Age: 20
*/
